﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;

namespace PrintScreens
{
    public partial class LegalStatementView : UserControl
    {
        public LegalStatementView()
        {
            InitializeComponent();
        }

        private void Update(string Name, bool ImageConsent, bool EmergencyConsent, string ContactConsent, bool Under18)
        {
            
            StringBuilder Value = new StringBuilder("");
            if ((EmergencyConsent | ContactConsent != "") && !Under18)
            {
                Value.Append("I consent to ");
                if (ContactConsent != "")
                {
                    Value.AppendFormat("my {0} being distributed to other club members", ContactConsent);
                    if (EmergencyConsent)
                    {
                        Value.Append(" and to ");
                    }
                }
                else
                {
                    Value.Append("I consent to my name appearing on membership lists");
                    if (EmergencyConsent)
                    {
                        Value.Append(" and to ");
                    }
                }
                if (EmergencyConsent)
                {
                    Value.Append("emergency numbers being published on the sign in sheet");
                }
                Value.Append(". ");
            }
            else if (!Under18)
            {
                Value.Append("I consent to my name appearing on membership lists, but none of my contact details.");
            }

            txtContactConsent.Text = Value.ToString();
            txtName.Text = Name;
            txtImageConsent.Text = (ImageConsent) ? "" : "do not" ;
            txtUnder18Statement.Visibility = (Under18) ? Visibility.Visible : Visibility.Collapsed;
            Over18CC.Visibility = (!Under18) ? Visibility.Visible : Visibility.Collapsed;
        }


        public Service.Printing.PrintingServiceMemberConsent ConsentDataContext
        {
            get { return (Service.Printing.PrintingServiceMemberConsent)GetValue(ConsentDataContextProperty); }
            set { SetValue(ConsentDataContextProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ConsentDataContext.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ConsentDataContextProperty =
            DependencyProperty.Register("ConsentDataContext", typeof(Service.Printing.PrintingServiceMemberConsent), typeof(LegalStatementView), new PropertyMetadata(null,
                (DO, DE) =>
                {
                    var value = DE.NewValue as Service.Printing.PrintingServiceMemberConsent;
                    var sender = DO as LegalStatementView;
                    if (value != null && sender != null)
                    {
                        sender.Update(value.MemberName, value.ImageConsent, value.EmergencyConsent, value.contactConsent, value.Under18);
                    }
                }));


    }
}
